<?php

use console\services\MigrateService;
use yii\db\Migration;

/**
 * Handles the creation of table `sys_position`.
 */
class m231229_144112_create_sys_position_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('sys_position', [
            'id' => $this->bigPrimaryKey(),
            'name' => $this->string(64)->defaultValue('')->notNull()->comment('名称'),
            'pos_key' => $this->string(64)->defaultValue('')->null()->comment('标识'),
            'status' => $this->char(1)->defaultValue('1')->null()->comment('状态'),
            'list_sort' => $this->bigInteger()->defaultValue(10)->null()->comment('排序'),
            'remark' => $this->string(255)->defaultValue('')->null()->comment('备注'),
            'create_time' => $this->bigInteger()->defaultValue(0)->null()->comment('创建时间'),
            'update_time' => $this->bigInteger()->defaultValue(0)->null()->comment('更新时间'),
        ], MigrateService::createTableOptions('岗位表'));

        $this->batchInsert('sys_position',
            ['id', 'name', 'pos_key', 'status', 'list_sort', 'remark', 'create_time', 'update_time'],
            [
                [1, '总经理', 'ceo', '1', 1, '', 1732850585, 1732850585],
                [2, '部门经理', 'cpo', '1', 2, '', 1732850585, 1732850585],
                [3, '组长', 'cgo', '1', 3, '', 1732850585, 1732850585],
                [4, '员工', 'user', '1', 4, '', 1732850585, 1732850585],
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('sys_position');
    }
}
